package com.hargasembako.core.entity;

import java.util.HashSet;
import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.hargasembako.core.util.SearchJanitor;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Product {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
	private Long id;	
	@Persistent
	private String code;	
	@Persistent
	private String name;	
	@Persistent
	private String unit;
	@Persistent
	private String category;
	@Persistent
	private String brand;
	@Persistent
	private String thumbnail;
    @Persistent
    private Set<String> fts;	
	
	public Product(String code, String name, String unit, String category, String brand) {
		this.code = code;
		this.name = name;
		this.unit = unit;
		this.category = category;
		this.brand = brand;
		
		this.fts = new HashSet<String>();
        
        SearchJanitor.updateFTSStuff(this.toString(), this.fts);		
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}	

	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}
	
	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	public String getThumbnail() {
		return thumbnail;
	}

	public void setThumbnail(String thumbnail) {
		this.thumbnail = thumbnail;
	}

	public Set<String> getFts() {
		return fts;
	}

	public void setFts(Set<String> fts) {
		this.fts = fts;
	}
	
	public String toString(){
		return code + " " + name + " " + unit + " " + category + " " + brand;		
	}

}
